package com.tsing.cedap.rest.controller;

import com.tsing.cedap.common.utils.ResultUtil;
import com.tsing.cedap.common.vo.ResultData;
import com.tsing.cedap.rest.service.IListService;
import com.tsing.cedap.rest.vo.reqVo.CodeReqVo;
import com.tsing.cedap.rest.vo.respVo.CampusTreeRespVo;
import com.tsing.cedap.rest.vo.respVo.IdAndNameRespVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @author TheTsing
 * @create 2022-01-26 11:37
 */

@Api(tags = "列表模块")
@RestController
@RequestMapping("/list")
public class ListController {

    @Autowired
    private IListService listService;

    @GetMapping("/schoolList")
    @ApiOperation(value = "学校列表")
    public ResultData<List<IdAndNameRespVo>> schoolList() {
        return ResultUtil.success(listService.schoolList());
    }

    @GetMapping("/campusList")
    @ApiOperation(value = "校区列表")
    public ResultData<List<IdAndNameRespVo>> campusList(@Validated CodeReqVo reqVo) {
        return ResultUtil.success(listService.campusList(reqVo));
    }

    @GetMapping("/collegeList")
    @ApiOperation(value = "学院列表")
    public ResultData<List<IdAndNameRespVo>> collegeList(@Validated CodeReqVo reqVo) {
        return ResultUtil.success(listService.collegeList(reqVo));
    }

    @GetMapping("/campusTree")
    @ApiOperation(value = "学校校区二级树")
    public ResultData<List<CampusTreeRespVo>> campusTree() {
        return ResultUtil.success(listService.campusTree());
    }

    @GetMapping("/courierStationTree")
    @ApiOperation(value = "根据校区id获取驿站树")
    public ResultData<List<CampusTreeRespVo>> courierStationTree(@Validated CodeReqVo reqVo) {
        return ResultUtil.success(listService.courierStationTree(reqVo));
    }

    @GetMapping("/addressList")
    @ApiOperation(value = "常用地址列表")
    public ResultData<List<IdAndNameRespVo>> addressList(HttpServletRequest request) {
        return ResultUtil.success(listService.addressList(request));
    }

    @GetMapping("/riderList")
    @ApiOperation(value = "注册服务人员列表")
    public ResultData<List<IdAndNameRespVo>> riderList(@Validated CodeReqVo reqVo) {
        return ResultUtil.success(listService.riderList(reqVo));
    }

    @GetMapping("/adminPhoneList")
    @ApiOperation(value = "校区管理人员电话列表")
    public ResultData<List<IdAndNameRespVo>> adminPhoneList(@Validated CodeReqVo reqVo) {
        return ResultUtil.success(listService.adminPhoneList(reqVo));
    }

    @GetMapping("/adminList")
    @ApiOperation(value = "运行人员列表")
    public ResultData<List<IdAndNameRespVo>> adminList() {
        return ResultUtil.success(listService.adminList());
    }

}
